import 'package:flutter/material.dart';
import 'package:flutter_app/values/MyColors.dart';
import 'package:flutter_app/widget/custom_app_bar.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import 'query_list_item/query_list_item_view.dart';
import 'query_list_logic.dart';

/**
 * @Description: 填报问题 清单列表
 * @Author: 下雨了
 * @CreateDate: 2022-7-14 16:19:52
 * @UpdateUser: 更新者
 * @UpdateDate:  2022-7-14 16:19:52
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
///
class QueryListPage extends StatefulWidget {
  final String title;

  const QueryListPage({Key? key, required this.title}) : super(key: key);

  @override
  _QueryListPageState createState() => _QueryListPageState();
}

class _QueryListPageState extends State<QueryListPage> {
  final logic = Get.put(QueryListLogic());
  final state = Get.find<QueryListLogic>().state;

  @override
  Widget build(BuildContext context) {
    return GetBuilder<QueryListLogic>(builder: (logic) {
      return Scaffold(
        backgroundColor: MyColors.FFF1F1F1,
        appBar: MyAppBar(context, title: widget.title,),
        body: SingleChildScrollView(
          child: Column(
            children: [
              Visibility(
                visible: (state.problemReportTypeEntity?.problemTypeList?.length ?? 0) > 0,
                child: Column(
                  children: [
                    Container(
                      margin: EdgeInsets.only(left: 16.r, top: 17.5, right: 16.r, bottom: 12.5.r),
                      child: Row(
                        children: [
                          Container(height: 18.5.r, width: 2.5.r,
                            margin: EdgeInsets.only(right: 3.r),
                            decoration: BoxDecoration(
                              gradient: LinearGradient(
                                begin: Alignment.topCenter,
                                end: Alignment.bottomCenter,
                                colors: [MyColors.FFF21617, MyColors.FFFF6938],
                              ),
                            ),
                          ),
                          Text("暗访问题清单", style: TextStyle(color: MyColors.FF333333, fontSize: 18.sp, fontWeight: FontWeight.w500),),
                        ],
                      ),
                    ),
                    Container(
                      margin: EdgeInsets.only(top: 12.5.r),
                      child: ListView.separated(
                        shrinkWrap: true,
                        physics: NeverScrollableScrollPhysics(),
                        padding: EdgeInsets.only(top: 0),
                        itemCount: state.problemReportTypeEntity?.problemTypeList?.length ?? 0,
                        itemBuilder: (BuildContext context, int index) {
                          return QueryListItemPage(index: index, list: state.problemReportTypeEntity?.problemTypeList![index],);
                        },
                        separatorBuilder: (BuildContext context, int index) {
                          return Divider(color: Colors.transparent, height: 10.r, thickness: 0.r,);
                        },
                      ),
                    ),
                  ],
                ),
              ),
              Visibility(
                visible: (state.problemReportTypeEntity?.taskTypeList?.length ?? 0) > 0,
                child: Column(
                  children: [
                    Container(
                      margin: EdgeInsets.only(left: 16.r, top: 27.5, right: 16.r),
                      child: Row(
                        children: [
                          Container(height: 18.5.r, width: 2.5.r,
                            margin: EdgeInsets.only(right: 3.r),
                            decoration: BoxDecoration(
                              gradient: LinearGradient(
                                begin: Alignment.topCenter,
                                end: Alignment.bottomCenter,
                                colors: [MyColors.FFF21617, MyColors.FFFF6938],
                              ),
                            ),
                          ),
                          Text("明查任务清单", style: TextStyle(color: MyColors.FF333333, fontSize: 18.sp, fontWeight: FontWeight.w500),),
                        ],
                      ),
                    ),
                    Container(
                      margin: EdgeInsets.only(top: 12.5.r, bottom: 12.5.r),
                      child: ListView.separated(
                        shrinkWrap: true,
                        physics: NeverScrollableScrollPhysics(),
                        padding: EdgeInsets.only(top: 0),
                        itemCount: state.problemReportTypeEntity?.taskTypeList?.length ?? 0,
                        itemBuilder: (BuildContext context, int index) {
                          return QueryListItemPage(index: index, list: state.problemReportTypeEntity?.taskTypeList![index],);
                        },
                        separatorBuilder: (BuildContext context, int index) {
                          return Divider(color: Colors.transparent, height: 10.r, thickness: 0.r,);
                        },
                      ),
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),
      );
    });
  }

  Widget ListItem() {
    return Container(
      margin: EdgeInsets.only(),
    );
  }

  @override
  void dispose() {
    Get.delete<QueryListLogic>();
    super.dispose();
  }
}
